package com.ytzl.servlet;


import com.ytzl.dao.Raindao;
import com.ytzl.dao.impl.Raindaoimpl;
import com.ytzl.pojo.Rains;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet(name="index",urlPatterns = {"/index"})
public class IndexServlet  extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request,
                         HttpServletResponse response)
            throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");

        //
        Raindao raindao =new Raindaoimpl();
        List<Rains> rainsList=raindao.getAll();

        //
        request.setAttribute("lists",rainsList);
        request.getRequestDispatcher("index.jsp").forward(request,response);

    }

}
